package com.zx.platform.context;

import com.zx.platform.service.DirectoryService;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * 数据字典信息
 *
 * @version 1.0
 */
@Controller
public class DirectoryInfoContext {

    private static List directInfoList;

    /**
     * 初始化及刷新
     */
    public static void initialize() {
        DirectoryService directoryService = (DirectoryService) ApplicationContextUtil.getContext().getBean("directoryService");
        directInfoList = directoryService.getDirectoryList();
    }

    public static List getDirectInfoList() {
        return directInfoList;
    }
    /**
     * 类似于系统参数功能
     * add by wenjw 
     * @return
     * @throws DataAccessException
     */
    public static String getValueByKeyAndCaption(String key, String dirCaption){
    	DirectoryService directoryService = (DirectoryService) ApplicationContextUtil.getContext().getBean("directoryService");
    	return directoryService.getValueByKeyAndCaption (key,  dirCaption);
    }
    
    /**
     * 类似于系统参数功能
     * add by wenjw 
     * @return
     * @throws DataAccessException
     */
    public static String getCaptionByKeyAndValue(String key, String value){
    	DirectoryService directoryService = (DirectoryService) ApplicationContextUtil.getContext().getBean("directoryService");
    	return directoryService.getCaptionByKeyAndValue(key,  value);
    }
}

